var waterline = require('../config/waterline');


module.exports = {
    //查询全部数据
    getList: function(param, next) {
        // console.log("param:", param);
        waterline.models.stationcoll
            .find(param)
            .exec(next);
    },
    //查询数量
    count: function(param, next) {
        waterline.models.stationcoll
            .count(param.requirement)
            .exec(next);
    },
    //查询一条数据
    getOne: function(param, next) {
        waterline.models.stationcoll
            .findOne(param)
            .exec(next);
    },
    //保存
    save: function(param, next) {
        // console.log(param);
        waterline.models.stationcoll.create(param, next);
    },
    /**
     * [pageList 分页查询]
     * @type {[limit]}表示返回的结果数量
     * @type {[skip]}表示跳过多少数量
     */
    pageList: function(param, next) {
        let pageLimit = param.page.pageSize;
        let pageSkip = (param.page.current - 1) * param.page.pageSize;
        // console.log(pageLimit, pageSkip)
        waterline.models.stationcoll
            .find({
                where: param.requirement,
                limit: pageLimit,
                skip: pageSkip
            })
            .exec(next);
    }
};